package com.epam.qanda.web.controller;

import java.util.List;
import java.util.concurrent.TimeUnit;

import com.epam.qanda.db.model.User;
import com.epam.qanda.db.service.UserService;

public class BanOff implements Runnable {

	@Override
	public void run() {
		while(true){
			UserService userService = new UserService();
			List<User> users =  userService.getAllBanedUsers();
			
			for (User user : users) {
				user.setStatus(false);
				user.setDateBanOff(null);
				userService.update(user);
			}
			
			try {
				TimeUnit.HOURS.sleep(24);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			
		}
	}

}
